class_name ArrayList

var arr:Array = []

func add(node):
	arr.append(node)

func addAll(list: ArrayList):
	for node in list.arr:
		add(node)
	return self

func size()->int:
	return arr.size()

func get(index):
	return arr[index]

func contains(node)->bool:
	for n in arr:
		if node == n:
			return true
		if node is BaseClass && node.equals(n):
			return true
	return false

func remove(index):
	arr.remove(index)
	
func removeObj(node):
	for i in range(arr.size()):
		var n = arr[i]
		if node is BaseClass && node.equals(n):
			arr.remove(i)
			i -= 1
		if node == n:
			arr.remove(i)
			i -= 1
	
func indexOf(p)->int:
	for x in range(arr.size()):
		var node = arr[x]
		if node == p:
			return x
		if node is BaseClass && node.equals(p):
			return x
	return -1

func isEmpty()->bool:
	return arr==null || arr.size()<=0
	
func copy(list):
	for a in list.arr:
		arr.append(a)

func clear():
	arr = []
